<?php
// +----------------------------------------------------------------------
// 调用远程接口
// +----------------------------------------------------------------------
// | Copyright (c) 2014 http://www.cencn.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: 彦子谷  <278805354@qq.com> <http://www.xzqly.com>
// +----------------------------------------------------------------------

namespace Common\Service;

use Common\Service\Service;
use Common\Service\NotobjectService;

class ApiService extends Service {

    public function useService($model = "") {
        if (empty($this->client)) {
            $this->_init();
        }
        //判断配置文件是否为空如果空的话那么就是用本地进行调用
        $rpc_api_url = C("HTTP_API_URL");
        if (empty($rpc_api_url)) {
            $rpc_api_url =  "http://" . $_SERVER['HTTP_HOST'] .__APP__.'/' .'Lapi/' . $model;
        } else {
            $rpc_api_url = $rpc_api_url . "/" . $model;
        }
       
 
    
        $this->client->useService($rpc_api_url);
        //判断是否是对象
        if (!is_object($this->client)) {
            //初始化一个对象给它
            $notobject = new NotobjectService();
            return $notobject;
        } else {
            return $this->client;
        }
    }

}
